home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_04
/
1004071a
< prev
next >
Wrap
Text File
|
1992-02-17
|
23KB
|
952 lines
/******************************************************************************
* Module : Lexical Analyzer --- Process the input text file into tokens
* that the parser can understand.
*
* Copyright (C) 1990 John W. M. Stevens, All Rights Reserved
*
* Routines : Lex - Return the next token from the file.
* OpenPrg - Open the source file.
* ParsErr - Report a parsing error.
*
* Author : John W. M. Stevens
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "lex.h"
/* Structure of trie branch. */
typedef struct key_st {
char c;
TKNS token;
struct key_st *child;
} NODE;
/* Constants local to this file. */
#define MAX_STR 256
#define NOT_FND -2
/* Object Data. */
static char word[MAX_STR + 1]; /* Last string analyzed. */
static char PrvWd[MAX_STR + 1]; /* Previous word. */
static int LnNo = 0; /* The current line number in the file. */
static FILE *PrgFl; /* File pointer. */
/* Trie data structure containing all the keywords and punctuation marks for
* the language being tokenized.
*/
static
NODE T5[2] = {
{ ' ', 2, NULL },
{ 'n', ACTION, NULL }
};
static
NODE T4[2] = {
{ ' ', 2, NULL },
{ 'o', 0, T5 }
};
static
NODE T3[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T4 }
};
static
NODE T2[2] = {
{ ' ', 2, NULL },
{ 't', 0, T3 }
};
static
NODE T8[2] = {
{ ' ', 2, NULL },
{ 'r', AFTER, NULL }
};
static
NODE T7[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T8 }
};
static
NODE T6[2] = {
{ ' ', 2, NULL },
{ 't', 0, T7 }
};
static
NODE T9[2] = {
{ ' ', 2, NULL },
{ 'd', AND, NULL }
};
static
NODE Te[2] = {
{ ' ', 2, NULL },
{ 'e', ARCHIVE, NULL }
};
static
NODE Td[2] = {
{ ' ', 2, NULL },
{ 'v', 0, Te }
};
static
NODE Tc[2] = {
{ ' ', 2, NULL },
{ 'i', 0, Td }
};
static
NODE Tb[2] = {
{ ' ', 2, NULL },
{ 'h', 0, Tc }
};
static
NODE Ta[2] = {
{ ' ', 2, NULL },
{ 'c', 0, Tb }
};
static
NODE T16[2] = {
{ ' ', 2, NULL },
{ 's', ATTRIBUTES, NULL }
};
static
NODE T15[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T16 }
};
static
NODE T14[2] = {
{ ' ', 2, NULL },
{ 't', 0, T15 }
};
static
NODE T13[2] = {
{ ' ', 2, NULL },
{ 'u', 0, T14 }
};
static
NODE T12[2] = {
{ ' ', 2, NULL },
{ 'b', 0, T13 }
};
static
NODE T11[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T12 }
};
static
NODE T10[2] = {
{ ' ', 2, NULL },
{ 'r', 0, T11 }
};
static
NODE Tf[2] = {
{ ' ', 2, NULL },
{ 't', 0, T10 }
};
static
NODE T1[6] = {
{ ' ', 6, NULL },
{ 'c', 0, T2 },
{ 'f', 0, T6 },
{ 'n', 0, T9 },
{ 'r', 0, Ta },
{ 't', 0, Tf }
};
static
NODE T1b[2] = {
{ ' ', 2, NULL },
{ 'e', BEFORE, NULL }
};
static
NODE T1a[2] = {
{ ' ', 2, NULL },
{ 'r', 0, T1b }
};
static
NODE T19[2] = {
{ ' ', 2, NULL },
{ 'o', 0, T1a }
};
static
NODE T18[2] = {
{ ' ', 2, NULL },
{ 'f', 0, T19 }
};
static
NODE T17[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T18 }
};
static
NODE T23[2] = {
{ ' ', 2, NULL },
{ 'y', DIRECTORY_T, NULL }
};
static
NODE T22[2] = {
{ ' ', 2, NULL },
{ 'r', 0, T23 }
};
static
NODE T21[2] = {
{ ' ', 2, NULL },
{ 'o', 0, T22 }
};
static
NODE T20[2] = {
{ ' ', 2, NULL },
{ 't', 0, T21 }
};
static
NODE T1f[2] = {
{ ' ', 2, NULL },
{ 'c', 0, T20 }
};
static
NODE T1e[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T1f }
};
static
NODE T1d[2] = {
{ ' ', 2, NULL },
{ 'r', 0, T1e }
};
static
NODE T1c[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T1d }
};
static
NODE T26[2] = {
{ ' ', 2, NULL },
{ 'c', EXEC, NULL }
};
static
NODE T25[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T26 }
};
static
NODE T24[2] = {
{ ' ', 2, NULL },
{ 'x', 0, T25 }
};
static
NODE T2a[2] = {
{ ' ', 2, NULL },
{ 's', FILES, NULL }
};
static
NODE T29[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T2a }
};
static
NODE T28[2] = {
{ ' ', 2, NULL },
{ 'l', 0, T29 }
};
static
NODE T27[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T28 }
};
static
NODE T2f[2] = {
{ ' ', 2, NULL },
{ 'n', HIDDEN, NULL }
};
static
NODE T2e[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T2f }
};
static
NODE T2d[2] = {
{ ' ', 2, NULL },
{ 'd', 0, T2e }
};
static
NODE T2c[2] = {
{ ' ', 2, NULL },
{ 'd', 0, T2d }
};
static
NODE T2b[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T2c }
};
static
NODE T33[2] = {
{ ' ', 2, NULL },
{ 'l', LABEL, NULL }
};
static
NODE T32[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T33 }
};
static
NODE T31[2] = {
{ ' ', 2, NULL },
{ 'b', 0, T32 }
};
static
NODE T30[2] = {
{ ' ', 2, NULL },
{ 'a', 0, T31 }
};
static
NODE T3a[2] = {
{ ' ', 2, NULL },
{ 'd', MODIFIED, NULL }
};
static
NODE T39[2] = {
{ ' ', 2, NULL },
{ 'e', 0, T3a }
};
static
NODE T38[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T39 }
};
static
NODE T37[2] = {
{ ' ', 2, NULL },
{ 'f', 0, T38 }
};
static
NODE T36[2] = {
{ ' ', 2, NULL },
{ 'i', 0, T37 }
};
static
NODE T35[2] = {
{ ' ', 2, NULL },
{ 'd', 0, T36 }
};
static
NODE T34[2] = {
{ ' ', 2, NULL },
{ 'o', 0, T35 }
};
static
NODE T3d[2] = {
{ ' ', 2, NULL },
{ 'e', NAME, NULL }
};
static
NODE T3c[2] = {
{ ' ', 2, NULL },
{ 'm', 0, T3d }
};
static
NODE T3e[2] = {
{ ' ', 2, NUL